from django.db import models

class Boy(models.Model):
    name = models.CharField(max_length=32)

class Girl(models.Model):
    name = models.CharField(max_length=32)

class B2G(models.Model):
    bid = models.ForeignKey(verbose_name="男生id", to="Boy", to_field="id", on_delete=models.CASCADE)
    gid = models.ForeignKey(verbose_name="女生id", to="Girl", to_field="id", on_delete=models.CASCADE)
    address = models.CharField(verbose_name="地址", max_length=32)

class Depart(models.Model):
    """部门"""
    title = models.CharField(verbose_name='部门名称', max_length=32)

class Admin(models.Model):
    """管理员"""
    name = models.CharField(verbose_name='姓名', max_length=32)
    pwd = models.CharField(verbose_name='密码', max_length=64)
    depart = models.ForeignKey(verbose_name='部门', to='Depart', to_field='id', on_delete=models.CASCADE)

class Role(models.Model):
    title = models.CharField(verbose_name='角色名称', max_length=32)
    od = models.IntegerField(verbose_name='排序', default=0)

    def __str__(self):
        return "{}-{}".format(self.id, self.title)

class UserInfo(models.Model):
    name = models.CharField(verbose_name="姓名", max_length=32, db_index=True)
    pwd = models.CharField(verbose_name="密码", max_length=32)

class Blog(models.Model):
    user = models.OneToOneField(to="UserInfo", on_delete=models.CASCADE)

    blog = models.CharField(verbose_name="博客地址", max_length=255)
    summary = models.CharField(verbose_name="简介", max_length=255)